package be.aiao.uibinder_tutorial.client.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class HelloWidgetWorld extends Composite {

	private static HelloWidgetWorldUiBinder uiBinder = GWT
			.create(HelloWidgetWorldUiBinder.class);

	@UiTemplate("HelloWidgetWorld.ui.xml")
	interface HelloWidgetWorldUiBinder extends
			UiBinder<Widget, HelloWidgetWorld> {
	}

	public HelloWidgetWorld() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField
	Button btnSubmit;

	@UiField
	TextBox txtName;
	
	public HelloWidgetWorld(String firstName) {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiHandler("btnSubmit")
	void onClick(ClickEvent e) {
		Window.alert("Hello " + txtName.getValue() + " !");
	}

}
